<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title></title>
  </head>
  <style>
    *{padding: 0;margin: 0;}
    .box{
      width: 200px;
      height: 200px;
      background: #ccc;
      transform: translate(0,0);
    }
  </style>
  <body>
    <div class="box"></div>
    <script>
      let boxDom = document.querySelectorAll(".box")[0];
      console.log(boxDom)
      boxDom.addEventListener("touchstart",function(e){
        let x = e.targetTouches[0].pageX - this.offsetLeft;
        let y = e.targetTouches[0].pageY - this.offsetTop;
        function move(e){
          let xx = e.targetTouches[0].pageX - x;
          let yy = e.targetTouches[0].pageY - y;
          boxDom.style.transform= `translate(${xx}px,${yy1}px)`;
        }
        function end(e){
          boxDom.removeEventListener("touchmove",move,false) 
          boxDom.removeEventListener("touchend",end,false) 
        }
        boxDom.addEventListener("touchmove",move,false);
        boxDom.addEventListener("touchend",end,false);
      },false)
    </script>
  </body>
</html>
